import JSEncrypt from 'jsencrypt';

const RASkey =
    'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAprftPX5SYvYNtF1xTF4S3Ju4r6qkmog+ssUtKQ0RZWSzc8Dv9tULjBzYpCMGPVUV+cb4uBWRxwS/O2uSsv0qkC5QmztJsOGp5oWjuRKWT3MFwjyWdqdfpKbZWzMXUzafVGZOiKb/aQBRcyRmtyyytyKXH1iBky2I9Pfs2KsfJXW8O3Z2iX2wZEQfJAo8ZX5QU8UtStPNAx/I5qmy8Os24HXk4y3t5Ig8Ovsl5S/UuXrs5p68vIWu5Os5GCprKi9rfANwpOZRqRryz+RTfk1iXzjo4bM54RPbcr4SxSHpL7t3JLc2SN8Isf1H6NXvWmGYClbn5vGJa706QKido4tAcwIDAQAB'; //这个是公钥   后端生成 或者前端自己用方法生成   前端只能纯公钥

/**
 * @: RSA加密
 * @param {string} str
 * @return {*}
 */
export function encryptRSA(str: string) {
    const encrypt = new JSEncrypt({ default_key_size: '2048' });
    encrypt.setPublicKey(RASkey);
    const data = encrypt.encrypt(str) as string;
    return data;
}
